import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2021/10/14
 * Time: 10:27
 * Description:
 */
public class HomeWork {

    //n->100
    public static double sumFunc(int n) {
        double sum = 0;
        int flg = 1;
        for (int i = 1; i <= n; i++) {
            sum = sum + 1.0/i * flg;
            flg = -flg;//-1
        }
        return sum;
    }
    //A of B  B的A
    public static int nineOfNum(int n) {
        int count = 0;
        for (int i = 1; i <= n; i++) {
            if(i % 10 == 9) {
                count++;
            }else if( i / 10 == 9) {
                count++;
            }
        }
        return count;
    }
    //0-999999
    public static void func(int n) {
        for (int i = 1; i <= n; i++) {
            int count = 0;
            int tmp = i;
            //i可能是一个3  4   5  6 第一步 求i是几位数
            while (tmp != 0) {
                count++;
                tmp = tmp/10;//12  1   0
            }
            tmp = i;//123
            int sum = 0;
            while (tmp != 0) {
                //        3,
                sum = sum + (int)Math.pow(tmp%10,count);
                tmp /= 10;//12
            }
            if(sum == i) {
                System.out.println(i);
            }
        }
    }

    public static void login() {
        Scanner scanner = new Scanner(System.in);
        int count = 3;
        while (count != 0) {
            System.out.println("请输入你的密码：");
            String pass = scanner.nextLine();
            //if(pass == "123456") { 重点
            if(pass.equals("123456")) {
                System.out.println("登录成功！");
                break;
            }else {
                count--;
                System.out.println("你还有："+count+"次机会！");
            }
        }
        if(count == 0) {
            System.out.println("你没有机会了！");
        }
    }


    public static int oneOfNum1(int n) {
        int count = 0;
        for (int i = 0; i < 32; i++) {
            if(((n>>>i)&1) == 1) {
                count++;
            }
        }
        return count;
    }

    public static int oneOfNum2(int n) {
        int count = 0;
        while (n != 0) {
            if((n & 1) != 0) {
                count++;
            }
            n = n>>>1;
        }
        return count;
    }

    public static int oneOfNum(int n) {
        int count = 0;
        while (n != 0) {
            n = n & (n-1);
            count++;
        }
        return count;
    }
    
    public static void func2(int n) {
        //偶数
        for (int i = 31; i >= 1 ; i-=2) {
            System.out.print(((n>>i)&1)+" ");
        }
        System.out.println();
        //奇数
        for (int i = 30; i >= 0 ; i-=2) {
            System.out.print(((n>>i)&1)+" ");
        }
    }

    public static void print(int n) {
        while (n != 0) {
            System.out.println(n % 10);
            n = n / 10;
        }
    }

    public static void main(String[] args) {
        print(123);

        short a =128;

        byte b =(byte) a;//a变量

        System.out.println(a);
        System.out.println(b);

        //\"hello\"

        System.out.println("\\\"hello\\\"");

        /* System.out.println(oneOfNum(-1));//32
        System.out.println(oneOfNum(6));//2
        System.out.println(oneOfNum(11));//3
       func(999999);
        System.out.println(nineOfNum(100));
        System.out.println(sumFunc(100));
        System.out.println(sumFunc(10));*/
    }
}
